@echo off
echo ========================================
echo 智慧社区微信小程序 - 后端服务启动脚本
echo ========================================
echo.
echo 需要启动的6个后端服务：
echo - 用户服务 (User Service):     localhost:8100
echo - 交换服务 (Swap Service):     localhost:8101
echo - 区域服务 (Region Service):   localhost:8102
echo - 搭子服务 (Buddy Service):    localhost:8103
echo - 社区服务 (Community Service): localhost:8104
echo - 教师服务 (Teacher Service):  localhost:8105
echo.
echo 请确保每个服务都在对应的端口上运行。
echo.
echo 启动步骤：
echo 1. 找到每个后端服务的项目目录
echo 2. 在每个目录中运行启动命令（通常是 npm start 或 yarn start）
echo 3. 确保服务监听正确的端口
echo.
echo 或者，如果使用Docker：
echo docker-compose up -d
echo.
echo 启动完成后，按任意键测试连接...
pause >nul

echo.
echo 测试服务连接...
echo.

echo Testing User Service (8100)...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8100/health' -TimeoutSec 5; Write-Host '✓ User Service is running' } catch { Write-Host '✗ User Service not responding' }"

echo Testing Swap Service (8101)...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8101/health' -TimeoutSec 5; Write-Host '✓ Swap Service is running' } catch { Write-Host '✗ Swap Service not responding' }"

echo Testing Region Service (8102)...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8102/health' -TimeoutSec 5; Write-Host '✓ Region Service is running' } catch { Write-Host '✗ Region Service not responding' }"

echo Testing Buddy Service (8103)...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8103/health' -TimeoutSec 5; Write-Host '✓ Buddy Service is running' } catch { Write-Host '✗ Buddy Service not responding' }"

echo Testing Community Service (8104)...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8104/health' -TimeoutSec 5; Write-Host '✓ Community Service is running' } catch { Write-Host '✗ Community Service not responding' }"

echo Testing Teacher Service (8105)...
powershell -Command "try { $response = Invoke-WebRequest -Uri 'http://localhost:8105/health' -TimeoutSec 5; Write-Host '✓ Teacher Service is running' } catch { Write-Host '✗ Teacher Service not responding' }"

echo.
echo 测试完成。如果有服务未运行，请检查对应的后端项目。
echo.
pause